<?php
/**
 * Created by PhpStorm.
 * User: zhangxinke
 * Date: 2019/6/1
 * Time: 11:11
 */

namespace app\api\model;


class PassworkModel extends BaseModel
{
    protected $table = "xst_user";//数据表
    public function pwdupdate($pwdtwo,$id){//修改密码
        return $this->where('id',$id)->update(
            [
                'login_pwd'=>authcode($pwdtwo,'ENCODE')
            ]
        );
    }
  	//查询详情
    public function user_list($id)
    {
      return $this->where('id',$id)->find();
    }
  
    public function forgetpwd(){
        $nickname = request()->post('nickname');
        $phone = request()->post('phone');
        $smcode = request()->post('smcode');
        $sm = new SmModel();
        $res = $sm->where('phone',$phone)
            ->order('id desc')
            ->limit(0,1)
            ->select();
        if($res[0]['code']!=$smcode&&$res[0]['invalidtime']>=time())
        {
            return $stu = ['code'=>0,'message'=>'验证码不正确'];
        }else{
            return $stu = ['code'=>1,'message'=>'验证码正确'];
        }
    }
    public function forgetpwds($phone)
    {
        $login_pwd = request()->post('login_pwd');
        $login_pwds = request()->post('login_pwds');
        if($login_pwd!=$login_pwds)
        {
            return $stu = ['code'=>0,'message'=>'两次密码不同！'];
        }else{
             return $res=$this
            ->where('phone',$phone)
            ->update(
                ['login_pwd'=>authcode($login_pwd,'ENCODE')]
            );
        }
       
    }
}